
<?php

$_id=$_POST["id"];
$login=$_POST["login"];
$_pass=$_POST["pass"];
$comment=$_POST["comment"];
$lat=$_POST["lat"];
$lng=$_POST["lng"];



$config_sql=file_get_contents("../config_sql.txt");
$arr_config_sql=  explode("!",$config_sql);

$hostname= "$arr_config_sql[1]";


$username = "$arr_config_sql[2]";


$password = "$arr_config_sql[3]";

$db = mysql_connect($hostname, $username, $password) //соединение с базой данных
        or die('connect to database failed');


$table_db=	"$arr_config_sql[4]"; // название таблицы базы
mysql_select_db($table_db) or die('db not found'); //соединение  с базой данных
mysql_query("SET NAMES utf8");
$res = mysql_query("SELECT * FROM user WHERE name ='$login'");

if (mysql_num_rows($res) > 0) {
    while ($row = mysql_fetch_array($res)) {
        $pass_db = $row['pass'];
        $device = $row['device'];
        $options = $row['options'];
    }
    // $devices =$device;
    $devices = json_encode($device);
    if ($_pass == $pass_db) {

        $options = json_decode($options, true);
      //  echo $options['event'];
        if ($options['event'] === 'true') {
            //   echo $options['event'];
            $event = 1;
            $event_change = 1;
            $event_confirm = 1;
        }
    }
}






if($event==1 && $event_change==1 && $event_confirm==1){
$tableBd="contact_personal";

$res = mysql_query("SELECT * FROM contact ORDER BY `user`");
$user = '';
$data = '';
$count = 0;
while($row = mysql_fetch_array($res)){
     $cart[$count] = array(
				"user" => $row['user'],
				"email" => $row['email'],
				"_id" => $row['id'],
				"is_alert" => $row['is_alert'],
				"phone1" => $row['phone1'],
			    "phone2" => $row['phone2'],
                "phone3" => $row['phone3'],
                "phone4" => $row['phone4'],
				"is_alert1" => $row['is_alert1'],
			    "is_alert2" => $row['is_alert2'],
			    "is_alert3" => $row['is_alert3'],
			    "is_alert4" => $row['is_alert4']
				);
	 $count++;
    }

echo json_encode( $cart );
}



?>